package helpers.preloaders
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.ProgressEvent;
	
	import mx.events.FlexEvent;
	import mx.preloaders.DownloadProgressBar;
	
	public class SwfPreloader extends DownloadProgressBar
	{
		public var wcs:WelcomeScreen;
		
		public function SwfPreloader()
		{
			super();
			wcs = new WelcomeScreen();
			this.addChild(wcs)  
		}
		
		override public function set preloader( preloader:Sprite ):void   
		{                     
			preloader.addEventListener(ProgressEvent.PROGRESS, SWFDownloadProgress);      
			preloader.addEventListener(Event.COMPLETE, SWFDownloadComplete);  
			preloader.addEventListener(FlexEvent.INIT_PROGRESS, FlexInitProgress);  
			preloader.addEventListener(FlexEvent.INIT_COMPLETE, FlexInitComplete);  
			this.wcs.addEventListener(wcs.COMPLETE_EVENT, wcsComplete);  
		}  
		
		private function SWFDownloadProgress(event : ProgressEvent):void {}  
		
		private function SWFDownloadComplete(event : Event):void {}  
		
		private function FlexInitProgress(event : Event):void {}  
		
		private function FlexInitComplete(event : Event):void   
		{                 
			wcs.ready = true;  
		}  
		
		
		
		private function wcsComplete(event : Event) : void  
		{  
			wcs.ready = true;  
			dispatchEvent(new Event( Event.COMPLETE));  
		}
	}
}